package org.gitman.agentplatform.agent.impl.test.factory;

import java.util.HashMap;
import java.util.Map;

import org.gitman.agentplatform.agent.api.Agent;
import org.gitman.agentplatform.agent.api.AgentFactory;
import org.gitman.agentplatform.agent.impl.test.agent.Test3Agent;
import org.gitman.agentplatform.core.exceptions.BadArgsException;

public class AgentFactoryTest2Impl implements AgentFactory{
private Map<Class<? extends Agent>, String> map;
	
	public AgentFactoryTest2Impl() {
		map = new HashMap<Class<? extends Agent>, String>();
		map.put(Test3Agent.class, "This is descr for new test 3 agent");
	}
	
	@Override
	public Agent getAgentImpl(Class<? extends Agent> clazz, String args) throws BadArgsException{
		Agent agent = null;
		try {
			agent = clazz.newInstance();
			agent.init(args);
		} catch (Exception e) {
			throw new BadArgsException("can't create new agent: " + clazz.getName());
		}
		return agent;
	}

	
	@Override
	public Map<Class<? extends Agent>, String> getAvailableAgents() {
		return map;
	}
	

}
